<?php
namespace modules\game\services\method;

class TwoKing extends IMethod{
	public static $_name = __CLASS__;

	//检测牌
	public function test(Array $testPoker){
		$this->_testNum = count($testPoker);
		$this->_testPoker = $testPoker;
		if($this->_testNum !== 2) return false;
		return (int)floor($this->_testPoker[0]/10) === 17 
				&& (int)floor($this->_testPoker[1]/10) === 18;
	}
	/**
	 * 出牌策略
	 * @param  array $userPoker 用户当前的牌,已模块
	 * [
	 * 	 1 => [11,13],
	 * 	 2 => [21],
	 * 	 5 => [53],
	 * 	 13 => [131,132,133],
	 * ]
	 * @return array 出的牌 | bool 没有此类型的牌，不出
	 * [
	 * 		21,
	 * ]
	 */
	public function out($userPoker){//出牌
		$poker = [];
		isset($userPoker[17]) &&  ($poker[] = current($userPoker[17]));
		isset($userPoker[18]) &&  ($poker[] = current($userPoker[18]));
		if($poker){
			//检测
			if($this->test($poker)){
				return $poker;
			}
		}
		return false;

	}
	/**
	 * 压牌策略
	 * @param  array $userPoker     我目前的牌
	 * @param  array $opponentPoker 当前需要被压的牌
	 * @param  bool  $intense  是否尽力压牌  true是  or false 否
	 * @return array  出牌 | bool: false 压不住
	 */
	public function suppress($userPoker,$opponentPoker,$intense){
		return $this->out($userPoker);
	}

}